\" Copyright (C) 2013 Jeff Epler <jepler@unpythonic.net>
\"
\" This program is free software; you can redistribute it and/or
\" modify it under the terms of the GNU General Public License
\" as published by the Free Software Foundation; either version 2
\" of the License, or (at your option) any later version.
\"
\" This program is distributed in the hope that it will be useful,
\" but WITHOUT ANY WARRANTY; without even the implied warranty of
\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
\" GNU General Public License for more details.
\"
\" You should have received a copy of the GNU General Public License
\" along with this program; if not, write to the Free Software
\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
.TH rtapi_div_u64 "3rtapi" "2006-10-12" "LinuxCNC Documentation" "RTAPI"
.SH NAME

rtapi_div_u64 \- unsigned division of a 64-bit number by a 32-bit number

.SH SYNTAX
.HP
__u64 rtapi_div_u64_rem(__u64 \fIdividend\fR, __u32 \fIdivisor\fR, __u32 *\fIremainder\fR)
.HP
__u64 rtapi_div_u64(__u64 \fIdividend\fR, __u32 \fIdivisor\fR)
.HP
__s64 rtapi_div_s64(__s64 \fIdividend\fR, __s32 \fIdivisor\fR)
.HP
__s64 rtapi_div_s64_rem(__s64 \fIdividend\fR, __s32 \fIdivisor\fR, __s32 *\fIremainder\fR)

.SH  ARGUMENTS
.IP \fIdividend\fR
The value to be divided
.IP \fIdivisor\fR
The value to divide by
.IP \fIremainder\fR
Pointer to the location to store the remainder.  This may not be a NULL
pointer.  If the remainder is not desired, call \fBrtapi_div_u64\fR or
\fBrtapi_div_s64\fR.

.SH DESCRIPTION
Perform integer division (and optionally compute the remainder) with a 64-bit dividend and 32-bit divisor.

.SH RETURN VALUE
The result of integer division of \fIdividend / divisor\fR.  In versions with the \fIremainder\fR argument, the remainder is stored in the pointed-to location.

.SH NOTES
If the result of the division does not fit in the return type, the result is
undefined.

This function exists because in kernel space the use of the division operator
on a 64-bit type can lead to an undefined symbol such as __umoddi3 when the
module is loaded.

.SH REALTIME CONSIDERATIONS
May be called from init/cleanup code and from within realtime tasks.
Available in userspace components.
